<?php

namespace App\Models;

use App\Models\Traits\ResetDateTime;
use App\Traits\ImagePath;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;

class Acc extends Authenticatable implements JWTSubject
{
    use Notifiable, ImagePath, ResetDateTime;

    protected $table = 'acc';
    protected $primaryKey = 'acc_user_id';
    public $timestamps = false;

    const ACC_STATUS = [
        'normal' => 10,
        'vfy' => 15,
        'pause' => 105,
        'stop' => 110,
        'forbidden' => 120,
    ];

    const ACC_DEV_TYPE = [
        'ios' => 1,
        'android' => 5,
    ];

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'acc_lg_pwd',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [

    ];

    protected $appends = [];

    /**
     * Get the identifier that will be stored in the subject claim of the JWT.
     *
     * @return mixed
     */
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    /**
     * Return a key value array, containing any custom claims to be added to the JWT.
     *
     * @return array
     */
    public function getJWTCustomClaims()
    {
        return [];
    }

    public function getAvatarAttribute($value)
    {
        return (string)$this->setPath($value);
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'acc_user_id', 'user_id');
    }
}
